$(document).ready(function(){
	active();
	initArticleReading();
});
function getArticleByCollecting(size,index){
	var url = "/HyperIT/article/getArticleByCollect";
	var parm = "size="+size+"&indexPageNum="+index+"&status=1";
	$.get(url,parm,function(data){
		if (data.serviceResult) {
			var list = data.resultParm.article_user;
			 showArticle(list);
		} else{
			messageTip(data.resultInfo);
		}
	});
}
function getArticleByReward(size,index){
	var url = "/HyperIT/article/getArticleByReward";
	var parm = "size="+size+"&indexPageNum="+index+"&status=1";
	$.get(url,parm,function(data){
		if (data.serviceResult) {
			var list = data.resultParm.article_user;
			 showArticle(list);
		} else{
			messageTip(data.resultInfo);
		}
	});
}
function getArticleByTime(size,index){
	var url = "/HyperIT/article/getArticle";
	var parm = "size="+size+"&indexPageNum="+index+"&status=1";
	$.get(url,parm,function(data){
		if (data.serviceResult) {
			var list = data.resultParm.article_user;
			 showArticle(list);
		} else{
			messageTip(data.resultInfo);
		}
	});
}
function getArticleBySearch(size,index){
	if($("#articleSearch").val().trim()==""){
		messageTip("请输入标签的关键字");
	}else{
		$(".article-items .article-item").remove();
		var url = "/HyperIT/article/searchArticle";
		var parm = "size="+size+"&indexPageNum="+index+"&status=1&search="+$("#articleSearch").val();
		$.get(url,parm,function(data){
			if (data.serviceResult) {
				var list = data.resultParm.article_user;
				 showArticle(list);
			} else{
				messageTip(data.resultInfo);
			}
		});
	}
}
function active(){
	$("#ranking ul").children("li").click(function(){
		$(this).addClass("active").siblings().removeClass("active");
		selectCard($(this).index());
	});
}
function selectCard(index){
	switch (index){
		case 0:
			initArticleReading();
			break;
		case 1:
			initArticleReward();
			break;
		case 2:
			initArticleCollecting();
			break;
		case 3:
			initArticleTime();
			break;
		default:
			break;
	}
}
function initArticleReading(){
	$(".article-items .article-item").remove();
	getArticleByReading(100000,1);
}
function initArticleReward(){
	$(".article-items .article-item").remove();
	getArticleByReward(1000000,1);
}
function initArticleCollecting(){
	$(".article-items .article-item").remove();
	getArticleByCollecting(100000,1);
}
function initArticleTime(){
	$(".article-items .article-item").remove();
	getArticleByTime(1000000,1);
}
